<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

use DB;
class GrowController extends Controller
{
    public function run(){
        //获取今天的日期
        $today = date('Y-m-d');
        //在tasks表中,只要是大于今天日期的都应该得到收益
        $task = DB::table('tasks')->where('enddate','>=',$today)->get();
        // dd($task);
        //循环为每个人写入收益信息
        foreach($task as $t){
            $t->paytime = $today;
            $t = (array)$t;
            unset($t['tid']);
            unset($t['enddate']);
            DB::table('grows')->insert($t);
            
        }
    }
}
